/**
 * 
 */
package com.agrec.client;

import com.agrec.client.actors.Name;
import com.agrec.client.services.KMRServiceAsync;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * @author allomeen
 *
 */
public class ReferFriendPage extends Composite implements KMRPage {

	private KMRServiceAsync kmrService;
	private FlexTable mainTable;
	private FlexTable handledByTable;
	private Name kmrUser;
	private ReferFriendForm referFriendForm;
	private Image userPhoto;
	private VerticalPanel handledByPanel;
	private String wtext;
	private Hyperlink usersCVL;
	private Label usersPos;

	/**
	 * 
	 */
	public ReferFriendPage(KMRServiceAsync kmrService) {
		this.kmrService = kmrService;
		mainTable = new FlexTable();
		handledByTable = new FlexTable();
		referFriendForm = new ReferFriendForm(kmrService);
		
		//this sgould be coming from DB with id
		kmrUser = new Name();
		kmrUser.firstName("Tariq");
		kmrUser.lastName("Al-Kahily");
		
		
		Label header = new Label("Refer a professional to " + kmrUser.firstName());
		wtext = new String("Its easy, all you need is to know is the manager's job title, where he works, and his contacts ... I will do the rest<br /><br />");
		
		//Foe HandledBy table
		userPhoto = new Image("images/tariq.jpg");
		handledByPanel = new VerticalPanel();
		
		usersCVL = new Hyperlink(kmrUser.firstName()+" "+kmrUser.lastName(),"UserCV");
		usersCVL.addClickHandler(new ClickHandler(){

			public void onClick(ClickEvent event) {
				CVViewer cvViewer = new CVViewer(kmrUser);
				AGRecDialogBox dialogBox = new AGRecDialogBox(true, cvViewer);
				dialogBox.setText(kmrUser.firstName()+" "+kmrUser.lastName());
				//dialogBox.setSize("300px", "300px");
				dialogBox.center();
				dialogBox.show();
				
				//BlindedPopup cvViewerPopup = new BlindedPopup(kmrUser.firstName()+" "+kmrUser.lastName(), cvViewer);
				//cvViewerPopup.show();
				
			}});
		usersPos = new Label("Recruitment Consultant");
		
		handledByPanel.add(usersCVL);
		handledByPanel.add(usersPos);
		
		handledByTable.setWidget(0, 0, userPhoto);
		handledByTable.setWidget(0, 1, handledByPanel);
		
		mainTable.setWidget(0, 0, header);
		mainTable.setWidget(1, 0, new HTML(wtext));
		mainTable.setWidget(2, 0, handledByTable);
		mainTable.setWidget(3, 0, referFriendForm);
		
		initWidget(mainTable);
	}

	/* (non-Javadoc)
	 * @see com.agrec.client.KMRPage#historyName()
	 */
	public String historyName() {
		return "ReferFriendPage";
	}

	/* (non-Javadoc)
	 * @see com.agrec.client.KMRPage#update()
	 */
	public void update() {
		// TODO Auto-generated method stub

	}

}
